#pragma once
#if 0
#include<QThread>
#include <memory>
#include <functional>
#include <queue>
#include <QBuffer>
#include "comLib\VideoDecoder.h"
#include <common\MsgDef.h>
#include <common\singletonPattern.h>
#include <common\def.h>

class CNet;
class DMsgCenter;

class DDataProcess :public CTcpServerListener
{
public:
	DDataProcess(QObject *parent = nullptr);
	~DDataProcess();
	std::vector<CONNID> getConnid();

protected:
	EnHandleResult OnPrepareListen(ITcpServer* pSender, SOCKET soListen) override;
	EnHandleResult OnAccept(ITcpServer* pSender, CONNID dwConnID, UINT_PTR soClient) override;
	EnHandleResult OnHandShake(ITcpServer* pSender, CONNID dwConnID) override;
	EnHandleResult OnReceive(ITcpServer* pSender, CONNID dwConnID, const BYTE* pData, int iLength)	 override;
	EnHandleResult OnSend(ITcpServer* pSender, CONNID dwConnID, const BYTE* pData, int iLength)	 override;
	EnHandleResult OnClose(ITcpServer* pSender, CONNID dwConnID, EnSocketOperation enOperation, int iErrorCode) override;
	EnHandleResult OnShutdown(ITcpServer* pSender)	 override;

	void run(const HeadInfo &headInfo, const void *data);

private:
	struct PacketStruct{
		bool bCompleteHead;
		HeadInfo headInfo;
		QByteArray *buffer;

		PacketStruct(){
			bCompleteHead = false;
			buffer = nullptr;
		}
	};

private:
	bool ProcessImage(const HeadInfo, const void *);
	bool ProcessImageSize(const HeadInfo, const void *);

private:
	typedef std::map <CLIENT_MSG,std::function<bool(const HeadInfo , const void *)>> MsgProcess;

	int m_iHeadSize;
	std::vector<CONNID> m_connId;
	//std::queue<NetPacket> m_PacketQueue;
	std::map<int, PacketStruct> m_RecvPacket;

	MsgProcess m_MsgProcess;
	CVideoDecoder *m_videoDecoder;
	DMsgCenter	*m_pMsgCenter;
	AVPacket *m_pPkt;
};

class DNetServer :public SingleTon<DNetServer>
{
public:
	~DNetServer();
	void sendPacket(HeadInfo headInfo, const char *data);

private:
	DNetServer();

private:
	friend class SingleTon < DNetServer > ;
	std::shared_ptr<DDataProcess> m_pDataProcess;

	ITcpServer *m_pTcpServer;
	std::string m_BindIp;
};
#endif